package org.john.auth.server.controller;

import org.john.common.util.InternalAssertion;
import org.springframework.beans.factory.annotation.Autowired;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public abstract class BaseController {

    @Autowired
    protected HttpServletRequest request;

    @Autowired
    protected HttpServletResponse response;

    protected ServletContext getServletContext() {
        return request.getSession().getServletContext();
    }

    protected String redirect(String path) {
        InternalAssertion.notEmpty(path, "redirect path cannot be empty.");
        path = path.trim();
        return "redirect:" + path;
    }
}
